#include "precompiled.h"
#include "svlTest.h"
//using namespace svlTest;

//
void svlTest::TestTText()
{
  char *S =
  "line0\r\n"
  "\r\n"
  "line1\r\n"
  "line2\r\n"
  "line3\r\n"
  "line4\r\n"
  "L"
  ;
  svl::TMem  Mem; Mem.Add((BYTE*)S,lstrlen(S));
  svl::TText Text(Mem);

  svl::TString SOut; for (int N = 0; N < Text.CountLines(); N++)
  {
    SOut << "[" << N << "]" << Text.GetLine(N) << "\r\n";
  }
  svl::TMessageModal((svl::TString&)SOut);
}

//
void svlTest::TestTNodeS()
{
  svl::TNodeS Root,*N1,*N2; Root.Name = "Root"; Root.Value = "root";
    N1 = Root.Children.NewLast(); N1->Name = "N1.1"; N1->Value = "n1.1";
      N2 = N1->Children.NewLast(); N2->Name = "N2.1"; N2->Value = 123;
      //N2 = N1->Children.NewLast(); N2->Name = "N2.2"; N2->Value = TDateTime::CurrentDateTime();
      N2 = N1->Children.NewLast(); N2->Name = "N2.2"; N2->Value = 0.345345;
    N1 = Root.Children.NewLast(); N1->Name = "N1.2"; N1->Value = "n1.2";
    N1 = Root.Children.NewLast(); N1->Name = "N1.3"; N1->Value = "n1.3";

  svl::TString S = Root.GetAsString();
  svl::TMessageModal((svl::TString&)S);
}

//
void svlTest::TestTPostMessage()
{
  struct TA : public svl::TPostMessage 
  {
    svl::TString S; TA(svl::TString S_) { S = S_; Post();}
    virtual void TPostMessage_Receive(void) 
    {
      svl::TMessageModal(svl::TString("Receive:") << S);
    }
  };
  for (int N = 1; N <= 3; N++)
  {
    new TA(N);
  }
}

//
void svlTest::Test()
{
  svl::TWindow Win; 
  ::MoveWindow(Win.Handle(),50,50,100,700,true); 
  Win.Show(); 

  TestTPostMessage();
  
  Win.MessagesLoop();
}
